import { Component } from '@angular/core'
interface List {
  name: string
}

@Component({
  selector: 'app-root',
  templateUrl: './app.component.html',
  styles: []
})
export class AppComponent {
  title = 'angular-test'
  username: string = ''
  list: List[] = [{ name: '张三' }, { name: '李四' }]
  // 添加
  change () {
    console.log(this.username)
    this.list.push({
      name: this.username
    })
  }
  // 删除
  remove (index: number) {
    console.log(index)
    this.list.splice(index, 1)
  }
}
